from setuptools import setup, Extension
from Cython.Build import cythonize
import numpy
import sys

# 根据平台选择合适的编译选项
if sys.platform == 'win32':
    # Windows下使用MSVC编译器选项
    extra_compile_args = ['/O2', '/fp:fast']
    extra_link_args = []
else:
    # Linux/Mac下使用gcc/clang选项
    extra_compile_args = ['-O3', '-march=native']
    extra_link_args = ['-O3']

# Cython扩展模块配置
extensions = [
    Extension(
        "cython_frame_comparer",
        sources=["cython_frame_comparer.pyx"],
        include_dirs=[numpy.get_include()],
        language="c++",
        extra_compile_args=extra_compile_args,
        extra_link_args=extra_link_args
    ),
    Extension(
        "cython_data_extractor", 
        sources=["cython_data_extractor.pyx"],
        include_dirs=[numpy.get_include()],
        language="c++",
        extra_compile_args=extra_compile_args,
        extra_link_args=extra_link_args
    )
]

setup(
    name="NOF_Cython_Extensions",
    ext_modules=cythonize(
        extensions,
        compiler_directives={
            "language_level": "3",
            "boundscheck": False,  # 关闭边界检查以提升性能
            "wraparound": False,   # 关闭负索引支持以提升性能
            "cdivision": True,     # 使用C风格除法
            "nonecheck": False,    # 关闭None检查
            "profile": False,      # 关闭性能分析
            "linetrace": False,    # 关闭行追踪
        }
    ),
    zip_safe=False,
) 